home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2010 April / PCA177.iso / ESSENTIALS / Firefox Setup.exe / nonlocalized / chrome / browser.jar / content / browser / certerror / aboutCertError.xhtml < prev   
Encoding:
Extensible Markup Language  |  2009-07-15  |  11.0 KB  |  280 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!DOCTYPE html [
  4.   <!ENTITY % htmlDTD
  5.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  6.     "DTD/xhtml1-strict.dtd">
  7.   %htmlDTD;
  8.   <!ENTITY % globalDTD
  9.     SYSTEM "chrome://global/locale/global.dtd">
  10.   %globalDTD;
  11.   <!ENTITY % certerrorDTD
  12.     SYSTEM "chrome://browser/locale/aboutCertError.dtd">
  13.   %certerrorDTD;
  14. ]>
  15.  
  16. <!-- ***** BEGIN LICENSE BLOCK *****
  17.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  18.    -
  19.    - The contents of this file are subject to the Mozilla Public License Version
  20.    - 1.1 (the "License"); you may not use this file except in compliance with
  21.    - the License. You may obtain a copy of the License at
  22.    - http://www.mozilla.org/MPL/
  23.    -
  24.    - Software distributed under the License is distributed on an "AS IS" basis,
  25.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  26.    - for the specific language governing rights and limitations under the
  27.    - License.
  28.    -
  29.    - The Original Code is netError.xhtml.
  30.    -
  31.    - The Initial Developer of the Original Code is
  32.    - Netscape Communications Corporation.
  33.    - Portions created by the Initial Developer are Copyright (C) 1998
  34.    - the Initial Developer. All Rights Reserved.
  35.    -
  36.    - Contributor(s):
  37.    -   Adam Lock <adamlock@netscape.com>
  38.    -   William R. Price <wrprice@alumni.rice.edu>
  39.    -   Henrik Skupin <mozilla@hskupin.info>
  40.    -   Jeff Walden <jwalden+code@mit.edu>
  41.    -   Johnathan Nightingale <johnath@mozilla.com>
  42.    -   Ehsan Akhgari <ehsan.akhgari@gmail.com>
  43.    -
  44.    - Alternatively, the contents of this file may be used under the terms of
  45.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  46.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  47.    - in which case the provisions of the GPL or the LGPL are applicable instead
  48.    - of those above. If you wish to allow use of your version of this file only
  49.    - under the terms of either the GPL or the LGPL, and not to allow others to
  50.    - use your version of this file under the terms of the MPL, indicate your
  51.    - decision by deleting the provisions above and replace them with the notice
  52.    - and other provisions required by the LGPL or the GPL. If you do not delete
  53.    - the provisions above, a recipient may use your version of this file under
  54.    - the terms of any one of the MPL, the GPL or the LGPL.
  55.    -
  56.    - ***** END LICENSE BLOCK ***** -->
  57. <html xmlns="http://www.w3.org/1999/xhtml">
  58.   <head>
  59.     <title>&certerror.pagetitle;</title>
  60.     <link rel="stylesheet" href="chrome://browser/skin/aboutCertError.css" type="text/css" media="all" />
  61.     <link rel="stylesheet" href="chrome://browser/content/certerror/aboutCertError.css" type="text/css" media="all" />
  62.     <!-- This page currently uses the same favicon as neterror.xhtml.
  63.          If the location of the favicon is changed for both pages, the
  64.          FAVICON_ERRORPAGE_URL symbol in toolkit/components/places/src/nsFaviconService.h
  65.          should be updated. If this page starts using a different favicon
  66.          than neterrorm nsFaviconService->DoSetAndLoadFaviconForPage
  67.          should be updated to ignore this one as well. -->
  68.     <link rel="icon" type="image/png" id="favicon" href="chrome://global/skin/icons/warning-16.png"/>
  69.  
  70.     <script type="application/x-javascript"><![CDATA[
  71.       // Error url MUST be formatted like this:
  72.       //   about:certerror?e=error&u=url&d=desc
  73.  
  74.       // Note that this file uses document.documentURI to get
  75.       // the URL (with the format from above). This is because
  76.       // document.location.href gets the current URI off the docshell,
  77.       // which is the URL displayed in the location bar, i.e.
  78.       // the URI that the user attempted to load.
  79.  
  80.       function getCSSClass()
  81.       {
  82.         var url = document.documentURI;
  83.         var matches = url.match(/s\=([^&]+)\&/);
  84.         // s is optional, if no match just return nothing
  85.         if (!matches || matches.length < 2)
  86.           return "";
  87.  
  88.         // parenthetical match is the second entry
  89.         return decodeURIComponent(matches[1]);
  90.       }
  91.  
  92.       function getDescription()
  93.       {
  94.         var url = document.documentURI;
  95.         var desc = url.search(/d\=/);
  96.  
  97.         // desc == -1 if not found; if so, return an empty string
  98.         // instead of what would turn out to be portions of the URI
  99.         if (desc == -1)
  100.           return "";
  101.  
  102.         return decodeURIComponent(url.slice(desc + 2));
  103.       }
  104.  
  105.       function initPage()
  106.       {
  107.         // Replace the "#1" string in the intro with the hostname.  Trickier
  108.         // than it might seem since we want to preserve the <b> tags, but
  109.         // not allow for any injection by just using innerHTML.  Instead,
  110.         // just find the right target text node.
  111.         var intro = document.getElementById('introContentP1');
  112.         function replaceWithHost(node) {
  113.           if (node.textContent == "#1")
  114.             node.textContent = location.host;
  115.           else
  116.             for(var i = 0; i < node.childNodes.length; i++)
  117.               replaceWithHost(node.childNodes[i]);
  118.         };
  119.         replaceWithHost(intro);
  120.         
  121.         if (getCSSClass() == "expertBadCert") {
  122.           toggle('technicalContent');
  123.           toggle('expertContent');
  124.         }
  125.         
  126.         var tech = document.getElementById("technicalContentText");
  127.         if (tech)
  128.           tech.textContent = getDescription();
  129.         
  130.         addDomainErrorLink();
  131.       }
  132.       
  133.       /* In the case of SSL error pages about domain mismatch, see if
  134.          we can hyperlink the user to the correct site.  We don't want
  135.          to do this generically since it allows MitM attacks to redirect
  136.          users to a site under attacker control, but in certain cases
  137.          it is safe (and helpful!) to do so.  Bug 402210
  138.       */
  139.       function addDomainErrorLink() {
  140.         // Rather than textContent, we need to treat description as HTML
  141.         var sd = document.getElementById("technicalContentText");
  142.         if (sd) {
  143.           var desc = getDescription();
  144.           
  145.           // sanitize description text - see bug 441169
  146.           
  147.           // First, find the index of the <a> tag we care about, being careful not to
  148.           // use an over-greedy regex
  149.           var re = /<a id="cert_domain_link" title="([^"]+)">/;
  150.           var result = re.exec(desc);
  151.           if(!result)
  152.             return;
  153.           
  154.           // Remove sd's existing children
  155.           sd.textContent = "";
  156.  
  157.           // Everything up to the link should be text content
  158.           sd.appendChild(document.createTextNode(desc.slice(0, result.index)));
  159.           
  160.           // Now create the link itself
  161.           var anchorEl = document.createElement("a");
  162.           anchorEl.setAttribute("id", "cert_domain_link");
  163.           anchorEl.setAttribute("title", result[1]);
  164.           anchorEl.appendChild(document.createTextNode(result[1]));
  165.           sd.appendChild(anchorEl);
  166.           
  167.           // Finally, append text for anything after the closing </a>
  168.           sd.appendChild(document.createTextNode(desc.slice(desc.indexOf("</a>") + "</a>".length)));
  169.         }
  170.  
  171.         var link = document.getElementById('cert_domain_link');
  172.         if (!link)
  173.           return;
  174.         
  175.         var okHost = link.getAttribute("title");
  176.         var thisHost = document.location.hostname;
  177.         var proto = document.location.protocol;
  178.  
  179.         // If okHost is a wildcard domain ("*.example.com") let's
  180.         // use "www" instead.  "*.example.com" isn't going to
  181.         // get anyone anywhere useful. bug 432491
  182.         okHost = okHost.replace(/^\*\./, "www.");
  183.  
  184.         /* case #1: 
  185.          * example.com uses an invalid security certificate.
  186.          *
  187.          * The certificate is only valid for www.example.com
  188.          *
  189.          * Make sure to include the "." ahead of thisHost so that
  190.          * a MitM attack on paypal.com doesn't hyperlink to "notpaypal.com"
  191.          *
  192.          * We'd normally just use a RegExp here except that we lack a
  193.          * library function to escape them properly (bug 248062), and
  194.          * domain names are famous for having '.' characters in them,
  195.          * which would allow spurious and possibly hostile matches.
  196.          */
  197.         if (endsWith(okHost, "." + thisHost))
  198.           link.href = proto + okHost;
  199.  
  200.         /* case #2:
  201.          * browser.garage.maemo.org uses an invalid security certificate.
  202.          *
  203.          * The certificate is only valid for garage.maemo.org
  204.          */
  205.         if (endsWith(thisHost, "." + okHost))
  206.           link.href = proto + okHost;
  207.           
  208.         // If we set a link, meaning there's something helpful for
  209.         // the user here, expand the section by default
  210.         if (link.href && getCSSClass() != "expertBadCert")
  211.           toggle("technicalContent");
  212.       }
  213.       
  214.       function endsWith(haystack, needle) {
  215.         return haystack.slice(-needle.length) == needle;
  216.       }
  217.  
  218.       function toggle(id) {
  219.         var el = document.getElementById(id);
  220.         if (el.getAttribute("collapsed"))
  221.           el.removeAttribute("collapsed");
  222.         else
  223.           el.setAttribute("collapsed", true);
  224.       }
  225.     ]]></script>
  226.   </head>
  227.  
  228.   <body dir="&locale.dir;">
  229.  
  230.     <!-- PAGE CONTAINER (for styling purposes only) -->
  231.     <div id="errorPageContainer">
  232.     
  233.       <!-- Error Title -->
  234.       <div id="errorTitle">
  235.         <h1 id="errorTitleText">&certerror.longpagetitle;</h1>
  236.       </div>
  237.       
  238.       <!-- LONG CONTENT (the section most likely to require scrolling) -->
  239.       <div id="errorLongContent">
  240.         <div id="introContent">
  241.           <p id="introContentP1">&certerror.introPara1;</p>
  242.           <p>&certerror.introPara2;</p>
  243.         </div>
  244.         
  245.         <div id="whatShouldIDoContent">
  246.           <h2>&certerror.whatShouldIDo.heading;</h2>
  247.           <div id="whatShouldIDoContentText">
  248.             <p>&certerror.whatShouldIDo.content;</p>
  249.             <xul:button xmlns:xul='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' id='getMeOutOfHereButton' label='&certerror.getMeOutOfHere.label;'/>
  250.           </div>
  251.         </div>
  252.         
  253.         <!-- The following sections can be unhidden by default by setting the
  254.              "browser.xul.error_pages.expert_bad_cert" pref to true -->
  255.         <div id="technicalContent" collapsed="true">
  256.           <h2 onclick="toggle('technicalContent');" id="technicalContentHeading">&certerror.technical.heading;</h2>
  257.           <p id="technicalContentText"/>
  258.         </div>
  259.         
  260.         <div id="expertContent" collapsed="true">
  261.           <h2 onclick="toggle('expertContent');" id="expertContentHeading">&certerror.expert.heading;</h2>
  262.           <div>
  263.             <p>&certerror.expert.content;</p>
  264.             <p>&certerror.expert.contentPara2;</p>
  265.             <xul:button xmlns:xul='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul' id='exceptionDialogButton' label='&certerror.addException.label;'/>
  266.           </div>
  267.         </div>
  268.       </div>
  269.     </div>
  270.  
  271.     <!--
  272.     - Note: It is important to run the script this way, instead of using
  273.     - an onload handler. This is because error pages are loaded as
  274.     - LOAD_BACKGROUND, which means that onload handlers will not be executed.
  275.     -->
  276.     <script type="application/x-javascript">initPage();</script>
  277.  
  278.   </body>
  279. </html>
  280.